<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/pageHead.jsp"%>
<link rel="stylesheet" type="text/css" href="${systemctx}/resources/css/table.css">
<script type="text/javascript">
	function view(val){
		var id = val;
		$(this).isswindow({
			noheader : true,
			url :"${systemctx}/topic/colunm/toColumnView.web?id="+id
		});
	}
	function addInfo(){
		$(this).isswindow({
			noheader : true,
			url :"${systemctx}/topic/colunm/toColumnAdd.web"
		});
	}
	
	var setting = {
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onClick: onClick
		}
	};
	
	var zNodes = ${treeJson};
	
	function onClick(event, treeId, treeNode) {
		$("#parentcolumnname").val(treeNode.name);
		$("#parentcolumn").val(treeNode.id);
		$(".treeColumn").css('display','none');
	}		
	$(document).ready(function(){
		$("#parentcolumnname").focus(function(){
			$.getJSON("${systemctx}/topic/colunm/getColumnListJson.json",function(data){
				zNodes = data;
				$.fn.zTree.init($("#treeDemo"), setting, zNodes);
			});
		});
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
	});
	
	function deleteColumn(id){
		if(confirm('<%=MessageResourcesUtils.getMessage(request, "alertinfo.common.jsp.alert2")%>')){
			$.get('${systemctx}/topic/colunm/deleteColumn.json?id=' + id,function(data){
				data = jQuery.parseJSON(data);
				if(data.messagetype == 1){
					alert(data.message);
					$('#datagrid').datagrid('load',$('#form1').serializeObject());
				}else {
					alert(data.message);
					return ;
				}
			});
		}
	}
	
	function query_datagrid(){
		//加载分页控件 datagrid
		$('#datagrid').issdatagrid({
			formid : 'form1',
			title : '<%=MessageResourcesUtils.getMessage(request, "topic.column.list.title")%>',
			singleSelect : true,
			striped : true,
			url : '${systemctx}/topic/colunm/getColumnJson.json',
			sortName: 'modifytime',
			sortOrder: 'desc',
			remoteSort : true,
			idField : 'id',
			rownumbers : true,
			queryParams:$('#form1').serializeObject(),
			frozenColumns :[[
 				/*{field:'ck', checkbox:true},*/
 				{field : 'id',title : '<%=MessageResourcesUtils.getMessage(request, "common.button.operation")%>',align : 'center',formatter : function(value,row,index) {
		      			var str = '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="editColumn(' + row.id + ')"><%=MessageResourcesUtils.getMessage(request,"common.button.update") %></a> ';
		      			str += '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="deleteColumn(' + row.id + ')"><%=MessageResourcesUtils.getMessage(request,"common.button.delete") %></a> ';
		    			return str;
	    			}
	        	},
 				{title : '<%=MessageResourcesUtils.getMessage(request,"topic.column.col.colunmcode")%>',field : 'columncode',sortable : true,align : 'left',formatter: function(value,row,index){
 					 	  return "<a href=\"javascript:void(0);\" onclick=\"view('"+row.id+"')\">"+value+"</a>";
 					  }
 				},  
 				{title : '<%=MessageResourcesUtils.getMessage(request,"topic.column.col.columnname")%>',field : 'columnname',sortable : true,align : 'left',width:150}, 
 			]],
 			columns : [[  
              	{title : '<%=MessageResourcesUtils.getMessage(request,"topic.column.col.parentcolumnname")%>',field : 'parentcolumnname',sortable : true,align : 'left',width:200},
              	{title : '<%=MessageResourcesUtils.getMessage(request,"topic.column.col.display")%>',field : 'display',sortable : true,align : 'left',width:200} 
            ]],
			onLoadSuccess : function(data) {

			}
		});
	}
	$(document).ready(function() {
		query_datagrid();
		$('#butQuery').click(function() {
			var parentcolumnname = $("#parentcolumnname").val();
			if(parentcolumnname==''){
				$('#parentcolumn').val('');
			}
			$('#datagrid').datagrid('load',$('#form1').serializeObject());
		});
		$("#display").selectutil({
			optModel : <%=SysConstant.Display.getMode1JSONString(true, false)%>,
			optDefault :''
		});
		
		$("#parentcolumnname").click(function(){
			$("#columnTree").css('display','block').css('left',$(this).offset().left);
		});
		
		$(".treeColumn").mouseleave(function(){
			$(".treeColumn").css('display','none');
		});
	});
	
	function editColumn(id){
		$(this).isswindow({
			noheader : true,
			url :'${systemctx}/topic/colunm/toColumnEdit.web?id='+id
		});
	}
	
</script>
<form action="" id="form1" name="form1">
	<div class="pageMain">
		<div class="pageTitle">
			<%=MessageResourcesUtils.getMessage(request, "systemmanage.contentmanagement.title")%>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "topic.column.title") %>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "topic.column.list.title")%>
		</div>
		<div class="pageBody">
			<table id="queryTable" class="formTableCommStyle">
				<tr>
					<td class="TableTd1">
						<i></i>
						<!-- 上级栏目 -->
						<%=MessageResourcesUtils.getMessage(request, "topic.column.col.parentcolumnname") %>
					</td>
					<td class="TableTd2">
						<input type="hidden" name="parentcolumn" id="parentcolumn">
						<input type="text" name="parentcolumnname" id="parentcolumnname">
						<div id="columnTree" class="treeColumn">
							<div class="zTreeDemoBackground left">
								<ul id="treeDemo" class="ztree"></ul>
							</div>
						</div>
					</td>
					<td class="TableTd3">
						<i></i>
						<!-- 是否显示 -->
						<%=MessageResourcesUtils.getMessage(request, "topic.column.col.display") %>
					</td>
					<td class="TableTd4">	
						<select name="display" id="display" class="validate[required]"></select>
					</td>
				</tr>
				<tr>
					<td class="TableTd1">
						<i></i>
						<%=MessageResourcesUtils.getMessage(request, "topic.column.col.columnname") %>
					</td>
					<td class="TableTd2">
						<input type="text" id="columnname" name="columnname" value=""/>
					</td>
					<td class="TableTd3"></td>
					<td class="TableTd4"></td>
				</tr>
			</table>
		</div>
		<div class="button-group">
			<input type="button" class="btn btn-default" id="butQuery" value="<%=MessageResourcesUtils.getMessage(request,"common.button.query") %>" />
			<input type="button" class="btn btn-default" onclick="addInfo()" value="<%=MessageResourcesUtils.getMessage(request,"common.button.add") %>" />
		</div>
		<table style="width: 100%">
			<tr>
				<td>
					<table id="datagrid"></table>
				</td>
			</tr>
		</table>				
	</div>
</form>

<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>